//
//  RootViewController.m
//  UI1_View_Label课后作业第二遍
//
//  Created by dllo on 15/11/7.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.view.backgroundColor = [UIColor colorWithRed:239 % 256 / 255.0 green:239 % 256 / 255.0 blue:239 % 256 / 255.0 alpha:1.0];
    
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(40, 100, 100, 30)];
    view1.backgroundColor = [UIColor clearColor];
    [self.view addSubview:view1];
    [view1 release];
    
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(view1.frame.origin.x, view1.frame.origin.y + view1.frame.size.height + 20, view1.frame.size.width, view1.frame.size.height)];
    view2.backgroundColor = [UIColor clearColor];
    [self.view addSubview:view2];
    [view2 release];
    
    UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(170, 100, 160, 30)];
    view3.backgroundColor = [UIColor clearColor];
    [self.view addSubview:view3];
    [view3 release];
    
    UIView *view4 = [[UIView alloc] initWithFrame:CGRectMake(170, 150, 160, 30)];
    view4.backgroundColor = [UIColor clearColor];
    [self.view addSubview:view4];
    [view4 release];
    
    UIView *view5 = [[UIView alloc] initWithFrame:CGRectMake(40, 200, 90, 30)];
    view5.backgroundColor = [UIColor clearColor];
    [self.view addSubview:view5];
    [view5 release];
    
    UIView *view6 = [[UIView alloc] initWithFrame:CGRectMake(139, 200, 90, 30)];
    view6.backgroundColor = [UIColor clearColor];
    [self.view addSubview:view6];
    [view6 release];
    
    UIView *view7 = [[UIView alloc] initWithFrame:CGRectMake(238, 200, 90, 30)];
    view7.backgroundColor = [UIColor clearColor];
    [self.view addSubview:view7];
    [view7 release];
    
    // label
    
    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    label1.text = @"登录名";
    label1.textColor = [UIColor purpleColor];
    label1.font = [UIFont boldSystemFontOfSize:27.0];
    [view1 addSubview:label1];
    [label1 release];
    label1.textAlignment = NSTextAlignmentCenter;
    
    
    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    label2.text = @"密码";
    label2.textColor = [UIColor purpleColor];
    label2.font = [UIFont boldSystemFontOfSize:27.0];
    [view2 addSubview:label2];
    [label2 release];
    label2.textAlignment = NSTextAlignmentCenter;
    
    
    // textfield
    
    UITextField *field1 = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 160, 30)];
    field1.text = @"请输入";
//    field1.placeholder = @"请输入";
    field1.clearButtonMode = UITextFieldViewModeAlways;
    field1.keyboardType = UIKeyboardTypePhonePad;
    field1.borderStyle = UITextBorderStyleBezel;
    [view3 addSubview: field1];
    [field1 release];
    
    UITextField *field2 = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 160, 30)];
//    field2.text = @"请输入密码";
    field2.placeholder = @"请输入密码";
    field2.secureTextEntry = YES;
    field2.keyboardType = UIKeyboardTypeDefault;
    field2.borderStyle = UITextBorderStyleRoundedRect;
    [view4 addSubview:field2];
    [field2 release];
    
    
    // button
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(0, 0, 90, 30);
    [button1 addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [button1 setTitle:@"登陆" forState:UIControlStateNormal];
    [button1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [view5 addSubview:button1];
    
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button2.frame = CGRectMake(0, 0, 90, 30);
    [button2 addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [button2 setTitle:@"注册" forState:UIControlStateNormal];
    button2.hidden = NO;
    [button2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [view6 addSubview:button2];
    
    
    UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
    button3.frame = CGRectMake(0, 0, 90, 30);
    [button3 addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [button3 setTitle:@"重置" forState:UIControlStateNormal];
    [button3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [view7 addSubview:button3];
    
    
    
    
    
    
    
    
    
    
    
    
}

- (void)buttonAction
{
    self.view.backgroundColor =[UIColor colorWithRed:(arc4random() % 256) /255.0 green:(arc4random() % 256) /255.0 blue:(arc4random() % 256) /255.0 alpha:1.0];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
